package com.totoro.spring.spring_demo.bean_post_process;

import com.totoro.spring.spring_demo.bean.DemoBean;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * Created by Niki on 2018/6/11 8:26
 */
@Component
public class BeanPostProcessDemo2 implements BeanPostProcessor {
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        if (bean instanceof DemoBean) {
            System.out.println("2---------->" + beanName + "process before initialization !");
        }
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        if (bean instanceof DemoBean) {
            System.out.println("2---------->" + beanName + "process after initialization !");
        }
        return bean;
    }
}
